<?php

namespace App\Http\Controllers\Home;

use App\Model\NewsModel;
use App\Model\OtherModel;
use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Input;

class OtherController extends CommonController
{
    //
    public function index()
    {
        $type =  Input::get('item_type');
        $item =  Input::get('oid');

        $navigate =  $this->navegate;
        $hot = NewsModel::where('type',3)->orderBy('create_time','desc')->limit(10)->get();

        $data = array();
        if($type==1){
          $data['list'] = OtherModel::where('item_type',1)->get();
          if(!$item){
              $data['first'] = OtherModel::orderBy('oid','desc')->first();
              $data['first']->click++;
              $data['first']->update();
          }else{
              $data['first'] = OtherModel::find($item);
          }
        }
        return view('home.other.index',compact('navigate','notice','hot','data'));
    }
}
